package org.giovanolli.mumi.dao.impl;

import org.giovanolli.mumi.dao.PatientEvaluationDao;
import org.giovanolli.mumi.entities.PatientEvaluation;
import org.giovanolli.mumi.entities.filter.EntityFilter;
import org.giovanolli.mumi.entities.filter.PatientEvaluationFilter;
import org.giovanolli.mumi.entities.filter.PatientLogFilter;
import org.hibernate.criterion.DetachedCriteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

/**
 * The Class PatientEvaluationDaoImpl.
 */
@Repository("patientEvaluationDao")
public class PatientEvaluationDaoImpl extends HibernateDao<PatientEvaluation> implements PatientEvaluationDao {

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.giovanolli.mumi.dao.impl.HibernateDao#fillCriteria(org.giovanolli .mumi.entities.filter.EntityFilter, org.hibernate.criterion.DetachedCriteria)
	 */
	@Override
	protected DetachedCriteria fillCriteria(EntityFilter<PatientEvaluation> filter, DetachedCriteria criteria) {
		final PatientEvaluationFilter entityFilter = (PatientEvaluationFilter) filter;

		if (entityFilter != null) {
			if (entityFilter.getPatient() != null) {
				criteria.add(Restrictions.eq("patient", entityFilter.getPatient()));
			}
		}
		return criteria;
	}

}
